﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using Kiss.Domain.OrderDataService;

namespace Kiss.Domain
{
    public class OrderDomain
    {
        OrderEntities data = new OrderEntities(new Uri(ConfigurationManager.AppSettings["OrderDataService"]));

        public List<Customer> GetCustomersByCity(string city)
        {
            var q = from c in data.CustomerSet
                    where c.City.Contains(city)
                    select c;

            return q.ToList();
        }

        public Customer GetCustomer(string id)
        {
            return data.CustomerSet.SingleOrDefault(c => c.CustomerID == id);
        }

        public void UpdateCustomer(Customer customer)
        {
            data.AttachTo("CustomerSet", customer);
            data.UpdateObject(customer);
            data.SaveChanges();
        }
    }
}
